package com.kb5173.search.index.utils;

import com.kb5173.search.common.define.enums.ResponseCodes;
import com.kb5173.search.common.entity.GoodsEO;
import com.kb5173.search.common.exception.IndexException;
import org.apache.commons.lang3.StringUtils;

/**
 * @author Chengfei.Sun
 */
public class DocumentUtil {
    /**
     * 生成索引主键
     *
     * @param goodsEO
     * @return
     */
    public static String geneIndexId(GoodsEO goodsEO) {
        if(StringUtils.isEmpty(goodsEO.getType())){
            throw new IndexException(ResponseCodes.EmptyType.getCode());
        }
        if(StringUtils.isEmpty(goodsEO.getOfferno())){
            throw new IndexException(ResponseCodes.EmptyOfferno.getCode());
        }
        return goodsEO.getType() + goodsEO.getOfferno();
    }
}
